package org.jeecg.modules.rooms.mapper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.business.entity.BusMarketMealCouponsUsed;
import org.jeecg.modules.rooms.entity.CesRoomLayoutPriceDate;

/**
 * @Description: ces_room_layout_price_date
 * @Author: jeecg-boot
 * @Date:   2023-03-23
 * @Version: V1.0
 */
public interface CesRoomLayoutPriceDateMapper extends BaseMapper<CesRoomLayoutPriceDate> {

    /**
     * 房价列表
     * @param page
     * @param hotelIds
     * @return
     */
    @Select("<script>select SUBSTR(MD5(RAND()),1,16) as id,max(h.name) as hotel_name,max(layout.name) as layout_name,max(price.name) as price_name,price.id as price_id\n" +
            "<foreach item='item' index='index' collection='dates' open=',' separator=',' close=' '>"+
            "ifnull(max(case date.date when '${item}' then date.price else null end),price.price) as '${item}' "+
            "</foreach>"+
            " from ces_room_layout layout inner join ces_room_layout_price price on price.layoutId=layout.id\n" +
            "left join ces_room_layout_price_date date on date.room_layout_price_id=price.id\n" +
            "left join bus_hotel_info h on h.id=layout.hotel_id\n"+
            "where price.invalid=0\n" +
            "<if test='hotelIds != null'> and layout.hotel_id in </if>"+
            "<foreach item='item' index='index' collection='hotelIds' open='(' separator=',' close=')'>"+
            " '${item}' "+
            "</foreach>"+
            "group by price.id </script>")
    public List<HashMap<String,Object>> pageList(Page<HashMap<String,Object>> page, @Param("dates") ArrayList<String> dates, @Param("hotelIds") ArrayList<String> hotelIds);

}
